import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: '',
    avatarUrl: '',
    nickName: ''
  },
  mutations: {
    login (state, payload) {
      const { userInfo } = payload
      state.avatarUrl = userInfo.avatarUrl
      state.nickName = userInfo.nickName
      state.token = payload.token
      // console.log(payload)
    }
  },
  actions: {
    login (store, payload) {
      store.commit('login', payload)
      // console.log(payload)
    }
  },
  modules: {
  }
})
